package com.mcptt.config.service.sub.sub;

import java.util.List;

import org.jdom.Element;
import org.jdom.JDOMException;

import com.cloudptt.api.product.log.Log;

public class TransmitTime {
	public static final String Name = "transmit-time";
	private static final String Name_TimeLimit = "time-limit";
	private static final String Name_TimeWarning = "time-warning";
	
	private String timeLimit = null;
	private String timeWarning = null;
	
	public void parse(Element elem) throws JDOMException
	{
		if(elem == null)
		{
			return;
		}
		List<Element> list = elem.getChildren();//��ø��ڵ���ӽڵ�  
		for(Element subElem:list) 
		{
			String name = subElem.getName();
			Log.debug(this.getClass(), "name = " + name);
			
			if(name == null
					|| name.length() <= 0)
			{
				return;
			}
			if(name.equals(Name_TimeLimit))
			{
				timeLimit = subElem.getText();
			}
			else if(name.equals(Name_TimeWarning))
			{
				timeWarning = subElem.getText();
			}
		}  
	}
	
	public String toString()
	{
		StringBuffer strBuf = new StringBuffer("\r\n");
		strBuf.append("<").append(Name).append(">").append("\r\n");
		
		strBuf.append("    ").append("<").append(Name_TimeLimit).append(">");
		strBuf.append(timeLimit);
		strBuf.append("</").append(Name_TimeLimit).append(">").append("\r\n");
		
		strBuf.append("    ").append("<").append(Name_TimeWarning).append(">");
		strBuf.append(timeWarning);
		strBuf.append("</").append(Name_TimeWarning).append(">").append("\r\n");

		strBuf.append("</").append(Name).append(">").append("\r\n");

		return strBuf.toString();
	}
}
